Skip to content

fix(validation): make dangerous-pattern refusal terminal and name the working bypass (#7) - #8

Merged
SWSAmor merged 1 commit into
mainfrom
fix/issue-7-terminal-refusal-message
Jun 23, 2026
Merged

SWSAmor merged 1 commit into
mainfrom
fix/issue-7-terminal-refusal-message

Conversation

@SWSAmor

@SWSAmor SWSAmor commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Summary

Implements direction #1 of #7: the defense-in-depth dangerous-pattern validator
returned a generic refusal that did not signal the block is terminal, so agents
retry-looped reworded variants on a non-retryable refusal.

The refusal message now:

  • states it is a terminal validation result (do not retry), which alone stops the retry-loops;
  • names the working server-side bypass — CODE_EXECUTOR_SKIP_DANGEROUS_PATTERNS=true env var / security.skipDangerousPatternCheck config (operator decision);
  • clarifies that the per-call skipDangerousPatternCheck request parameter is intentionally ignored for security (HIGH: skipDangerousPatternCheck flag bypasses ALL pattern validation aberemia24/code-executor-MCP#56), so callers are not misled into retrying with it;
  • stays generic — it never reveals which pattern matched (preserved security property).

Changes

  • src/validation/security-validator.ts — enriched refusal message (keeps the dangerous pattern substring for back-compat; one message per matched pattern is preserved, so the multi-pattern error contract still holds).
  • src/index.ts — corrected the misleading skipDangerousPatternCheck tool-description and zod schema text in both the executeTypescript and executePython registrations; it no longer implies a working per-call bypass.
  • tests/security/pattern-bypass.test.ts — added a Terminal refusal message guidance (Issue #7) block, and fixed a dead import (../../src/security.js → ../../src/validation/security-validator.js) that had silently disabled the whole file. 51 security regression tests run again.

Testing (TDD)

  • Red → green: 3 new message-guidance tests failed first, then passed after the fix.
  • tests/security/pattern-bypass.test.ts: 51/51 green.
  • tsc --noEmit: clean.
  • Binary rebuilt (npm run build:binary); closed-stdin smoke test exits 0.

No test pins the old message text, and the full-suite delta vs. baseline is the 51 resurrected tests plus pre-existing, network/runtime-flaky and broken-import files (unrelated to this change).

Scope / out of scope

Follow-ups (separate)

  • Other test files share the same dead-import breakage and never run: tests/security.test.ts, tests/handlers/tool-execution-handler.test.ts (likely more). Worth a dedicated cleanup PR.

Addresses #7 — direction #1 (and #3). Deliberately does not auto-close: direction #2
(false-positive reduction) remains open as a follow-up; close #7 manually if #2 is dropped.

🤖 Generated with Claude Code

… working bypass

The defense-in-depth dangerous-pattern validator returned a generic refusal
that did not signal the block is terminal, so agents retry-looped reworded
variants on a non-retryable refusal (issue #7).

- security-validator: the refusal now states it is a terminal result
  ("do not retry"), names the working server-side bypass
  (CODE_EXECUTOR_SKIP_DANGEROUS_PATTERNS env / security.skipDangerousPatternCheck
  config), and clarifies that the per-call skipDangerousPatternCheck request
  parameter is intentionally ignored (issue aberemia24#56). The message stays generic and
  never reveals which pattern matched.
- index: correct the misleading skipDangerousPatternCheck tool-description and
  schema text in both the executeTypescript and executePython registrations so
  it no longer implies a working per-call bypass.
- tests: add "Terminal refusal message guidance" cases and fix the dead import
  in pattern-bypass.test.ts (src/security.js -> src/validation/security-validator.js)
  that had silently disabled the whole file (51 regression tests now run again).

Scope: issue #7 direction #1 only (refusal message + discoverability).
False-positive reduction (context-aware matching) is intentionally out of scope.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@SWSAmor
SWSAmor merged commit b0231d0 into main Jun 23, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dangerous-pattern validator causes agent retry-loops (false positives on literal tokens)

1 participant